import babelEslint from 'babel-eslint'
import globals from 'globals'
import eslintJs from '@eslint/js'
import tseslint from 'typescript-eslint'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'

export default tseslint.config(
    {
        languageOptions: {
            globals: {
                ...globals.browser
            },
            parserOptions: {
                ecmaVersion: 2018,
                parser: babelEslint,
                sourceType: 'module'
            }
        }
    },
    eslintJs.configs.recommended,
    ...tseslint.configs.recommended,
    eslintPluginPrettierRecommended,
    {
        ignores: [
            'dist',
            'node_modules',
            '.vscode',
            '.git',
            'test.html',
            'server.js',
            '*.zip',
            '*.config.js',
            '*.yaml',
            'tsconfig.json'
        ]
    },
    {
        files: ['tool/*.ts'],
        rules: {
            'no-console': ['error', { allow: ['warn', 'error'] }],
            '@typescript-eslint/no-unused-vars': [
                'error',
                {
                    argsIgnorePattern: '^_'
                }
            ],
            semi: 0,
            'no-control-regex': 'off',
            '@typescript-eslint/no-explicit-any': 0,
            '@typescript-eslint/no-unsafe-function-type': 'off',
            'no-useless-escape': 0
        }
    }
)
